local fk__zhongyu = fk.CreateSkill {

  name = "fk__zhongyu",

  tags = {  },

}

local U = require "packages/utility/utility"


fk__zhongyu:addEffect(fk.EventPhaseStart, {
  name = "fk__zhongyu",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(fk__zhongyu.name) and target ~= player and target.phase == Player.Play
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, fk__zhongyu.name, nil, "#fk__zhongyu-invoke:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, fk__zhongyu.name)
    target:drawCards(1, fk__zhongyu.name)
    if (player:isAllNude() or target:isAllNude()) then return end
    local id1 = room:askForDiscard(player, 1, 1, true, fk__zhongyu.name, false, ".", "#fk__zhongyu-discard")[1]
    local id2 = room:askForDiscard(target, 1, 1, true, fk__zhongyu.name, false, ".", "#fk__zhongyu-discard")[1]
    if Fk:getCardById(id1).color == Fk:getCardById(id2).color then
      target:drawCards(1, fk__zhongyu.name)
    end
  end,
})

return fk__zhongyu